home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
151-175
/
scopedisk165
/
cliscreen
/
cliscreen.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-19
|
8KB
|
257 lines
/*
This is a very very simple program that just opens a one-bitplane
screen to run your CLIs on. This is useful for folks who are
using WorkBench 2.0 and have a 8- or 16-color WorkBench screen, but
hate the scrolling and update speed when they use the CLI or Shell.
It is easily solved by opening another screen and telling Intuition
that it is a WorkBench type screen. Then when you pop open a CLI or
other WorkBench application, if this screen is in front of the "real"
WorkBench, the CLI or application will open on it.
The default screen used is 640 X 400 with white text on a black
background. However, you may force it to be any size you so desire
by specifying the following parameters on the command line:
-w# Width desired.
-h# Height desired.
-b# Background color, specified as three hex digits. (RGB)
-t# Text color, specified as three hex digits. (RGB)
These parameters may appear in any order, and are not case
sensitive. So, if, for example, you wanted a medium resolution screen
with yellow text on a blue background, you would enter
cliscreen -w640 -h200 -b00F -tFF0
All screen sizes are supported, except the new screen modes in
WorkBench 2.0 (productivity, super-hires, etc.) (working on it).
This program will run fine from 1.2 or 1.3, as well as 2.0.
This source was written using SAS/C for the Amiga version 5.10.
It should be linked with cback.o in order to allow it to detach from
the CLI it was run from. I should think it would be trivial to port
to other compilers, since this is pretty trivial code, really. If
you have a PAL machine, you'll need to adjust the values in the
ReadArgs() routine to reflect the appropriate PAL sizes.
This source code is completely public domain. You can do whatever
your heart desires with it. But if you write something mean and nasty
with it, take my name off it first...
Enjoy.
-- Robert Kesterson
*/
#include <ios1.h> /* for Lattice stderr thing */
#include <exec/types.h>
#include <libraries/dos.h>
#include <proto/dos.h>
#include <intuition/intuition.h>
#include <ctype.h>
#include <stdlib.h>
/*
These variables are needed for cback.o to work the way it needs to.
If you're porting to another compiler, you'll probably want to pay
close attention to this part.
*/
LONG _stack = 4000L; /* may not even need that much */
char *_procname = "CLIScreen"; /* task name */
LONG _priority = 0L; /* will be asleep anyway */
LONG _BackGroundIO = 0L; /* not planning on any */
extern struct UFB _ufbs[]; /* also for stderr thing with Lattice */
/* Then these are just normal stuff */
struct TextAttr topazfont = { "topaz.font", 8, FS_NORMAL, FPB_ROMFONT };
struct NewScreen cli_screen =
{
0,0,640,400,1, /* left top wide high deep */
-1,-1, /* detail & block pens */
NULL, /* flags (fill in later) */
WBENCHSCREEN, /* screen type */
&topazfont, /* font */
"One-Plane CLI Screen", /* title */
NULL, /* gadgets (none) */
NULL, /* no custom bitmap */
};
struct NewWindow close_window =
{
0,0,150,11, /* left top wide high */
-1, -1, /* detail and block pens */
CLOSEWINDOW, /* IDCMP flags */
WINDOWCLOSE|WINDOWDRAG|SMART_REFRESH, /* other flags */
NULL, /* no gadgets */
NULL, /* no checkmark */
"Close to Exit", /* title (message, actually) */
NULL, /* screen pointer - fill below */
NULL, /* no superbitmap */
0,0,0,0, /* no resizing this one */
WBENCHSCREEN
};
struct IntuitionBase *IntuitionBase = NULL;
struct GfxBase *GfxBase = NULL;
struct Screen *screen = NULL;
struct Window *window = NULL;
struct IntuiMessage *msg = NULL;
SHORT wide = 640; /* got to watch those short wides... */
SHORT high = 400;
UWORD color0 = 0x0000; /* default colors for screen */
UWORD color1 = 0x0FFF;
void ReadArgs(int argc,char **argv);
BOOL OpenStuff(void);
BOOL CloseStuff(void);
/* ********************************************************************
the main() program...
There is a really obscure piece of code in there about _ufbs[2].ufbfh
being closed. All that is is closing the stderr output to allow the
shell to close. Why cback doesn't do this, I haven't the faintest.
******************************************************************** */
void main(argc,argv)
int argc;
char **argv;
{
if(!argc) /* CLI only, folks. */
exit(20);
if(_ufbs[2].ufbfh)
Close(_ufbs[2].ufbfh);
ReadArgs(argc,argv); /* get parameters */
if(!OpenStuff()) /* set everything up */
{
CloseStuff();
exit(10);
}
while(TRUE) /* hang around a while */
{
while(msg = (struct IntuiMessage *)GetMsg(window->UserPort)) /* clear it again */
ReplyMsg(msg);
WaitPort(window->UserPort); /* wait for message */
while(msg = (struct IntuiMessage *)GetMsg(window->UserPort)) /* clear it again */
ReplyMsg(msg);
if(CloseStuff()) /* wind it up */
break;
else
DisplayBeep(screen); /* can't leave just yet */
}
exit(0); /* th-th-th-that's all, folks! */
}
/* ********************************************************************
ReadArgs() just reads the command line arguments and sets up the
screen sizes and such from them.
******************************************************************** */
void ReadArgs(argc,argv)
int argc;
char **argv;
{
int count;
char *dummy = "dummy pointer";
for(count=1;count<argc;count++)
switch(toupper(argv[count][1]))
{
case 'W': /* set width */
cli_screen.Width = (SHORT)atol(&argv[count][2]);
break;
case 'H': /* set height */
cli_screen.Height = (SHORT)atol(&argv[count][2]);
break;
case 'B':
color0 = (UWORD)strtol(&argv[count][2], dummy, 16);
break;
case 'T':
color1 = (UWORD)strtol(&argv[count][2], dummy, 16);
break;
}
if(cli_screen.Width>384)
cli_screen.ViewModes |= HIRES;
if(cli_screen.Height > 240)
cli_screen.ViewModes |= LACE;
return;
}
/* ********************************************************************
OpenStuff() just sets up all the pointers, libraries, stuff like
that, for the rest of the program. It returns TRUE on success or
FALSE on failure.
******************************************************************** */
BOOL OpenStuff()
{
UWORD colorset[2];
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0);
if((!IntuitionBase) || (!GfxBase))
return FALSE;
screen = (struct Screen *)OpenScreen(&cli_screen);
if(!screen)
return FALSE;
close_window.Screen = screen; /* put window on this screen */
window = (struct Window *)OpenWindow(&close_window);
if(!window)
return FALSE;
colorset[0] = color0;
colorset[1] = color1;
LoadRGB4(ViewPortAddress(window),colorset,2);
ScreenToFront(screen); /* pop it into view */
return TRUE;
}
/* *******************************************************************
CloseStuff() just closes all the stuff it thinks is open. But first
it checks the window list to see if there are other windows out there.
If there are, it doesn't close anything. Returns TRUE on successful
closure, FALSE on error.
******************************************************************* */
BOOL CloseStuff()
{
struct Window *win;
win = screen->FirstWindow;
do /* check for visitors */
{
if(win != window)
return FALSE;
win = win->NextWindow;
}
while(win);
if(window) /* nobody here so close up */
CloseWindow(window);
if(screen)
CloseScreen(screen);
if(IntuitionBase)
CloseLibrary(IntuitionBase);
return TRUE;
}